﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using Ast = YAPL.Language.Ast;
using YAPL.Language.Compiler.CodeGen.ReflectionEmitGenerator.AstGen.Helpers;

namespace YAPL.Language.Compiler.CodeGen.ReflectionEmitGenerator.AstGen {
	public class ReUnaryGenerator : ReExpressionGenerator {
		public ReUnaryGenerator(ReCodeGenerator codeGenerator) : base(codeGenerator) {}
		public override void Generate(Ast.Expression expr) {
			var unaryExpr = (Ast.UnaryExpression)expr;
			var ilGen = Generator.Get<ILGenerator>(ReCodeGenerator.IL_GENERATOR_KEY);

			Generator.EmitExpression(unaryExpr.Operand);
			ilGen.EmitCallUnaryOperator(unaryExpr);
		}
	}
}
